package springbucks.controller;

import org.springframework.web.bind.annotation.GetMapping;
import springbucks.entity.ResultVO;
import springbucks.util.GlobalIdUtil;

import javax.annotation.Resource;

/**
 * @author wangyidi
 * @version V1.0
 * @Description 获取全局id
 * @date 2022/11/26 12:02 下午
 * @Copyright © 2022 中电金信-研究院
 */
public class GlobalIdController {

    @Resource
    private GlobalIdUtil globalIdUtil;

    private final static String GLOBAL_KEY = "springbucks";

    /**
     * @Description 获取全局id
     * @author wangyidi
     * @date 2022/11/23 5:06 下午
     * @return ResultVO
     **/
    @GetMapping(value = "/globalId")
    public ResultVO leaderboard() {
        Long id = globalIdUtil.nextID(GLOBAL_KEY);
        return ResultVO.success(id);
    }
}
